let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n108,
  i =
    (this && this.__extends) ||
    ((_n108 = function n(t, e) {
      return (_n108 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
    function (t, e) {
      function o() {
        this.constructor = t;
      }
      _n108(t, e),
        (t.prototype =
          null === e
            ? Object.create(e)
            : ((o.prototype = e.prototype), new o()));
    });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.HpBarCom = void 0);
var r = t('UIComponent'),
  a = t('AbsInfo'),
  s = t('ComUtils'),
  c = t('ResMrg'),
  l = cc.Vec2,
  u = t('BattleUtils'),
  h = t('HurtValueCom'),
  p = t('MathUtils'),
  f = (function (t) {
    function e(e, o) {
      var n = t.call(this, e) || this;
      return (
        o.on(a.InfoEvent.HPChanged, n.onHpChangedHandler, n),
        (n._actor = o),
        n.initCamp(n._actor.camp),
        n.refreshHP(!1),
        n
      );
    }
    return (
      i(e, t),
      (e.prototype.onInit = function () {
        t.prototype.onInit.call(this),
          (this._progress = this.view.getComponent(cc.ProgressBar)),
          (this.view.opacity = 0),
          (this.active = !1);
      }),
      Object.defineProperty(e.prototype, 'actor', {
        get: function get() {
          return this._actor;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.initCamp = function (t) {
        var o = s.default.getComponent(cc.Sprite, this.view, 'bar');
        c.ResMrg.loadSpriteByAtlas(o, 'Atlas/Battle', e.BarColor[t]),
          (this._progress.reverse = 2 == t);
      }),
      (e.prototype.onHpChangedHandler = function (t, e, o) {
        var n = h.HurtValueCom.get(e, o);
        (n.view.parent = this.view.parent),
          (n.view.x = this.view.x + p.default.randomInt(-30, 30)),
          (n.view.y = this.view.y + p.default.randomInt(-40, 0)),
          n.show(),
          (this.active = !0),
          this.view.stopAllActions(),
          this._actor.hp > 0
            ? cc
                .tween(this.view)
                .to(0.3, {
                  opacity: 255
                })
                .delay(u.default.VisibleHPBarTime)
                .to(0.3, {
                  opacity: 0
                })
                .call(this.hideView.bind(this))
                .start()
            : cc
                .tween(this.view)
                .to(0.3, {
                  opacity: 0
                })
                .call(this.hideView.bind(this))
                .start(),
          this.refreshHP();
      }),
      (e.prototype.hideView = function () {
        (this.view.opacity = 0), (this.active = !1);
      }),
      (e.prototype.refreshHP = function (t) {
        void 0 === t && (t = !0);
        var e = this._actor.hp / this._actor.info.hpMax;
        t
          ? cc
              .tween(this._progress)
              .to(0.1, {
                progress: e
              })
              .start()
          : (this._progress.progress = e);
      }),
      (e.prototype.onUpdate = function (e) {
        if ((t.prototype.onUpdate.call(this, e), this.view.parent)) {
          var o = this.actor.hang.convertToWorldSpaceAR(l.ZERO);
          ((o = this.view.parent.convertToNodeSpaceAR(o)).y += 10),
            this.view.setPosition(o);
        }
      }),
      (e.BarColor = {
        1: 'lvxuetiao',
        2: 'hongxuetiao'
      }),
      e
    );
  })(r.UIComponent);
(o.HpBarCom = f), console.log('end');
module.exports = e.exports;
